<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <ul id="app"></ul>
    <script>
        function getUserInfo() {
            var cookie = {},
                cookieArr = document.cookie.split(';');
            var str = null;
            var reg1 = null;
            var arr = null;
            var str2 = null;
            var strArr = null;

            cookieArr.forEach(function(e) {
                let item = e.split('=');
                cookie[item[0]] = item[1];
            });

            str = cookie['cookieUser'];
            reg1 = /%\S{2,2}/g;
            arr = [];
            str2 = str.replace(reg1, "%$%");
            strArr = str2.split(/%{1,}/);

            // 拆分，将ASCLL码放入arr数组中
            for (let i = 0; i < str.length; i++) {
                if (str[i] === '%') {
                    arr.push(str.substr(i + 1, 2));
                }
            }
            // 转码
            arr.forEach(function(e, i) {
                var a = parseInt(e, 16);
                arr[i] = String.fromCharCode(a);
            });
            // 替换
            for (let i = 0, j = 0; i < strArr.length; i++) {
                if (strArr[i] === "$") {
                    strArr[i] = arr[j];
                    j++;
                }
            }

            // console.log(allStr);
            return JSON.parse(strArr.join(''));
        }
    </script>
</body>

</html>